package org.example.commons.config;


import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 读取项目相关配置
 *
 * @author bothin
 */
@Configuration
@ConfigurationProperties(prefix = "bothin")
public class BothinProperties {


    private String host;

    /** 上传路径 */
    private static String profile;

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath()
    {
        return getProfile() + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getProfile() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath()
    {
        return getProfile() + "/upload";
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public static String getProfile() {
        return profile;
    }

    /**
     * 注意这里的set方法不能是静态方法，要不然无法注入yml中的值
     */
    public void setProfile(String profile) {
        BothinProperties.profile = profile;
    }
}
